package com.seehack.sample.spring.extension.feign;

import feign.Feign;
import feign.jaxrs.JAXRSContract;
import org.springframework.beans.factory.FactoryBean;

public class FeignClientFactoryBean implements FactoryBean<Object> {

    private Class<?> type;

    public FeignClientFactoryBean() {
        //intentionally empty
    }

    public FeignClientFactoryBean(Class<?> type) {
        this.type = type;
    }
    @Override
    public Object getObject() throws Exception {
        return Feign.builder()
                .contract(new JAXRSContract())
                .target(type,"https://api.github.com");
    }

    @Override
    public Class<?> getObjectType() {
        return type;
    }

    public void setType(Class<?> type) {
        this.type = type;
    }
}
